// Code generated by ent, DO NOT EDIT.

package forecast

import (
	"fmt"

	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
)

const (
	// Label holds the string label denoting the forecast type in the database.
	Label = "forecast"
	// FieldID holds the string denoting the id field in the database.
	FieldID = "id"
	// FieldTemperature holds the string denoting the temperature field in the database.
	FieldTemperature = "temperature"
	// FieldWindSpeed holds the string denoting the windspeed field in the database.
	FieldWindSpeed = "wind_speed"
	// FieldPrecipitationAmount holds the string denoting the precipitationamount field in the database.
	FieldPrecipitationAmount = "precipitation_amount"
	// FieldWeatherCondition holds the string denoting the weathercondition field in the database.
	FieldWeatherCondition = "weather_condition"
	// FieldDateTime holds the string denoting the datetime field in the database.
	FieldDateTime = "date_time"
	// EdgeRegion holds the string denoting the region edge name in mutations.
	EdgeRegion = "region"
	// EdgeRegionWeather holds the string denoting the regionweather edge name in mutations.
	EdgeRegionWeather = "regionWeather"
	// Table holds the table name of the forecast in the database.
	Table = "forecasts"
	// RegionTable is the table that holds the region relation/edge.
	RegionTable = "forecasts"
	// RegionInverseTable is the table name for the Region entity.
	// It exists in this package in order to avoid circular dependency with the "region" package.
	RegionInverseTable = "regions"
	// RegionColumn is the table column denoting the region relation/edge.
	RegionColumn = "forecast_region"
	// RegionWeatherTable is the table that holds the regionWeather relation/edge.
	RegionWeatherTable = "forecasts"
	// RegionWeatherInverseTable is the table name for the Weather entity.
	// It exists in this package in order to avoid circular dependency with the "weather" package.
	RegionWeatherInverseTable = "weathers"
	// RegionWeatherColumn is the table column denoting the regionWeather relation/edge.
	RegionWeatherColumn = "weather_forecast"
)

// Columns holds all SQL columns for forecast fields.
var Columns = []string{
	FieldID,
	FieldTemperature,
	FieldWindSpeed,
	FieldPrecipitationAmount,
	FieldWeatherCondition,
	FieldDateTime,
}

// ForeignKeys holds the SQL foreign-keys that are owned by the "forecasts"
// table and are not defined as standalone fields in the schema.
var ForeignKeys = []string{
	"forecast_region",
	"weather_forecast",
}

// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
	for i := range Columns {
		if column == Columns[i] {
			return true
		}
	}
	for i := range ForeignKeys {
		if column == ForeignKeys[i] {
			return true
		}
	}
	return false
}

var (
	// WindSpeedValidator is a validator for the "windSpeed" field. It is called by the builders before save.
	WindSpeedValidator func(float64) error
	// PrecipitationAmountValidator is a validator for the "precipitationAmount" field. It is called by the builders before save.
	PrecipitationAmountValidator func(float64) error
)

// WeatherCondition defines the type for the "weatherCondition" enum field.
type WeatherCondition string

// WeatherCondition values.
const (
	WeatherConditionCLEAR  WeatherCondition = "CLEAR"
	WeatherConditionCLOUDY WeatherCondition = "CLOUDY"
	WeatherConditionRAIN   WeatherCondition = "RAIN"
	WeatherConditionSNOW   WeatherCondition = "SNOW"
	WeatherConditionFOG    WeatherCondition = "FOG"
	WeatherConditionSTORM  WeatherCondition = "STORM"
)

func (wc WeatherCondition) String() string {
	return string(wc)
}

// WeatherConditionValidator is a validator for the "weatherCondition" field enum values. It is called by the builders before save.
func WeatherConditionValidator(wc WeatherCondition) error {
	switch wc {
	case WeatherConditionCLEAR, WeatherConditionCLOUDY, WeatherConditionRAIN, WeatherConditionSNOW, WeatherConditionFOG, WeatherConditionSTORM:
		return nil
	default:
		return fmt.Errorf("forecast: invalid enum value for weatherCondition field: %q", wc)
	}
}

// OrderOption defines the ordering options for the Forecast queries.
type OrderOption func(*sql.Selector)

// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldID, opts...).ToFunc()
}

// ByTemperature orders the results by the temperature field.
func ByTemperature(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldTemperature, opts...).ToFunc()
}

// ByWindSpeed orders the results by the windSpeed field.
func ByWindSpeed(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldWindSpeed, opts...).ToFunc()
}

// ByPrecipitationAmount orders the results by the precipitationAmount field.
func ByPrecipitationAmount(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldPrecipitationAmount, opts...).ToFunc()
}

// ByWeatherCondition orders the results by the weatherCondition field.
func ByWeatherCondition(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldWeatherCondition, opts...).ToFunc()
}

// ByDateTime orders the results by the dateTime field.
func ByDateTime(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldDateTime, opts...).ToFunc()
}

// ByRegionField orders the results by region field.
func ByRegionField(field string, opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newRegionStep(), sql.OrderByField(field, opts...))
	}
}

// ByRegionWeatherField orders the results by regionWeather field.
func ByRegionWeatherField(field string, opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newRegionWeatherStep(), sql.OrderByField(field, opts...))
	}
}
func newRegionStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(RegionInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, false, RegionTable, RegionColumn),
	)
}
func newRegionWeatherStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(RegionWeatherInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, true, RegionWeatherTable, RegionWeatherColumn),
	)
}
